﻿@model Infinity.BusinessLayer.CourseViewModel

@{
    ViewBag.Title = "EditeCourse";
    Layout = "~/Areas/Managerial/Views/Shared/_AdminLayout.cshtml";
}
<span style="color:red">
    @Html.ValidationSummary()
</span>
<section class="course-form">
    @using (Html.BeginForm("UpdateCourse", "Course"))
    {
        @Html.AntiForgeryToken()
        @Html.ValidationSummary(true)

        <h2> <strong>Edite Course</strong></h2>

       <div >
        <span class="input input--jiro">
            <label class="" for="input-10" style="color:gray">
                <span class="input__label-content input__label-content--jiro">
                    &nbsp;&nbsp; @Html.HiddenFor(model => model.CourseID)
                    Course ID
                    &nbsp;&nbsp;&nbsp;
                    @Model.CourseID
                </span>
            </label>
        </span>
        </div>
     <div >
        <span class="input input--jiro">
            <input class="input__field input__field--jiro" type="text" value="@Model.Course_Name" name="Course_Name" id="Course_Name" />
            <label class="input__label input__label--jiro " for="input-10">
                <span class="input__label-content input__label-content--jiro">
                    Course Name
                </span>
            </label>
        </span>
    </div>
        
        <br />
        <div >
            <span class="input input--jiro">
                <select class="input__field input__field--jiro" id="CategoryID" name="CategoryID" >
                    @foreach (var item in ViewBag.catList)
                        {
            <option value="@item.CategoryID">@item.Category_Name</option>
                        }
                </select>

                <label class="input__label input__label--jiro" for="input-19">
                    <span class="input__label-content input__label-content--jiro">Category</span>
                </label>
            </span>
        </div>
        <br />
         <div >
        <span class="input input--jiro">
            <input class="input__field input__field--jiro" type="text" value="@Model.Official_crs_hrs" name="Official_crs_hrs" id="Official_crs_hrs" />
            <label class="input__label input__label--jiro " for="input-10">
                <span class="input__label-content input__label-content--jiro">
                    Number of Hours
                </span>
            </label>
        </span>
             </div>
        <br />
        <div>Certificate <input type="checkbox" id="CheckCertificate" /></div>
         <div >
        <span class="input input--jiro">
            <input class="hideCertificate input__field input__field--jiro" type="text" value="@Model.Certificate" name="Certificate" id="Certificate" />
            <label class="hideCertificate input__label input__label--jiro " for="input-10">
                <span class="input__label-content input__label-content--jiro">
                    Certificate Price
                    <span class="Certificate">@Html.ValidationMessageFor(model => model.Certificate)</span>
                </span>
            </label>
        </span>
             </div>
        <br />
        <div>Material <input type="checkbox" id="CheckMaterial" /></div>
        <span class="input input--jiro">
            <input class="hideMaterial input__field input__field--jiro" value="@Model.Material" type="text" name="Material" id="Material" />
            <label class="hideMaterial input__label input__label--jiro " for="input-10">
                <span class="input__label-content input__label-content--jiro">
                    Material Price
                </span>
            </label>
        </span>
        <br />
        
       
        
        <span class="input input--jiro">
            <label class="" for="input-10" style="color:gray">
                <span class="input__label-content input__label-content--jiro">
                    &nbsp;&nbsp;
                    Exam
                    &nbsp;&nbsp;&nbsp;
                    @Html.CheckBoxFor(model => model.Exam)
                </span>
            </label>
        </span>
       
<div role="tabpanel" class="padding-90">

    <!-- Nav tabs -->
    <ul class="nav nav-tabs" role="tablist">
        <li role="presentation" class="active"><a href="#home" aria-controls="home" role="tab" data-toggle="tab">Course Price</a></li>
        <li role="presentation"> <a href="#profile" aria-controls="profile" role="tab" data-toggle="tab">Course Outline</a></li>

    </ul>

    <!-- Tab panes -->
    <div class="tab-content">
        <div role="tabpanel" class="tab-pane active" id="home">
            
                @foreach (var item in Model.course_grouptype)
                {
                    Html.RenderPartial("_course_grouptype", item);
                }
            <div class="col-md-12 text-center send3">
                <a href="#" class="send">ADD</a>
            </div>
        </div>


        <div role="tabpanel" class="tab-pane" id="profile">
            <div class="row">
                <div id="outLine">
                    @foreach (var item in Model.Outlines)
                    {
                        Html.RenderPartial("_Outline", item);
                    }
                </div>
                <br>
                <div class="col-md-12 text-center send3">
                    <a href="#" class="send">ADD</a>
                </div>
            </div>
            
        </div>


    </div>
</div>
   
        <div>
            <table>
                <tr>
                    <td>
                        <button class="send fromedite DeleteCourse" value="@Model.CourseID"> Delete</button>
                    </td>
                    <td>  @Html.ActionLink("Back to List", "Index", null, new { @class = "buttonstyle" })</td>
                    <td> @Html.ActionLink("Create new Course", "NewCourse", null, new { @class = "send" })</td>
                    <td>  <input type="submit" class="send" value="Save" /></td>
                </tr>
            </table>
        </div>
    }
  
</section>
<div style="height:200px"></div>

<script src="~/Content/js/jquery-1.11.2.min.js"></script>
<script>

    $(document).ready(function () {
        //--- check boxes value 
        //cetfication
        if ($("#Certificate").val) {
            $("#CheckCertificate").attr("checked", "checked");
        }
        else {
            $(".hideCertificate").hide();
        }
        // material
        if ($("#Material").val) {
            $("#CheckMaterial").attr("checked", "checked");
        }
        else {

            $(".hideMaterial").hide();
        }


        //---------------------------------------


       
        x();
        function x() {
            $("#CheckMaterial").click(function () {

                if ($("#CheckMaterial").is(":checked")) {

                    $(".hideMaterial").show();
                }
                else {

                    $(".hideMaterial").hide();
                }
            })
            $("#CheckCertificate").click(function () {
                if ($("#CheckCertificate").is(":checked")) {
                    $(".hideCertificate").show();

                }
                else { $(".hideCertificate").hide(); }
            })
        }

        //----- delete Course--------------------------------------------
        $(document).ready(function () {

            $(".DeleteCourse").click(function (a) {

                var caller = $(this);
                var id = $(this).val();
                var x = $(this).hasClass('fromedite');

                if (confirm("Are you sure you want to delete ?")) {
                    $.ajax({
                        type: "POST",
                        url: "/Managerial/Course/DeleteCourse",
                        data: { crsID: id },
                        success: function (list) {

                            if (x == true) {
                                location.href = '/Managerial/Course/Index';
                            }
                            else {
                                $('#CourseContainer').html(list);
                                alert("deleted Successfully");
                            }
                        },
                        error: function () {
                            alert("can't Delet it");
                        }
                    });
                }
            })
        })
    })

</script>

